package com.shujia.spark.mllib

import org.apache.spark.ml.classification.LogisticRegressionModel
import org.apache.spark.ml.linalg
import org.apache.spark.ml.linalg.Vectors
import org.apache.spark.sql.SparkSession

object Demo4Prodict {
  def main(args: Array[String]): Unit = {

    val spark: SparkSession = SparkSession
      .builder()
      .master("local")
      .appName("train")
      .getOrCreate()

    /**
      * 1 1:5.7 2:4.3 3:3.5 4:130.1 5:85.9 6:84.0 7:65
      * 0 1:5.7 2:4.3 3:2.7 4:120.5 5:79.1 6:72.4 7:75
      *
      */


    //加载模型
    val model: LogisticRegressionModel = LogisticRegressionModel.load("data/model")

    //    val data: linalg.Vector = Vectors.dense(5.7, 4.3, 3.5, 130.1, 85.9, 84.0, 65)
    val data: linalg.Vector = Vectors.dense(5.7, 4.3, 2.7, 120.5, 79.1, 72.4, 75)

    //预测
    val p: Double = model.predict(data)

    println(p)

  }

}
